#ifndef ISERIALIZABLE_HPP
#define	ISERIALIZABLE_HPP

#include <map>
#include <vector>
#include <string>

#include "tinyxml2.hpp"

using namespace tinyxml2;

enum VarType { BOOL, INT, FLOAT, STRING, BOOL_ARR, INT_ARR, FLOAT_ARR, STRING_ARR };

struct SerializedVar
{
    std::string name;
    void* value;
    VarType type;
    int valCount;
    
    SerializedVar(std::string n, void* v, VarType t)
    {
        name = n;
        value = v;
        type = t;
        valCount = 1;
    }
    
    SerializedVar(std::string n, void* v, VarType t, int count)
    {
        name = n;
        value = v;
        type = t;
        valCount = count;
    }
};

class Serializable 
{
    public:
        Serializable();
        virtual ~Serializable();

        XMLElement* Serialize(XMLDocument* doc, std::string name, XMLElement* parent=NULL);
        void Deserialize(XMLElement* root);
        void Deserialize(XMLDocument* root);
        void MarkSerializable(std::string name, bool* value);
        void MarkSerializable(std::string name, int* value);
        void MarkSerializable(std::string name, float* value);
        void MarkSerializable(std::string name, std::string* value);
        void MarkSerializable(std::string name, int valCount, bool* array);
        void MarkSerializable(std::string name, int valCount, int* array);
        void MarkSerializable(std::string name, int valCount, float* array);
        void MarkSerializable(std::string name, int valCount, std::string* array);
        
        void Dump();
    private:
        std::vector<SerializedVar> _variables;
};

#endif

